#ifndef SIMPLE_STRUCT_DEFINE_
#define SIMPLE_STRUCT_DEFINE_

#include <string>
#include <vector>

enum{
    Cmd_Type_Register_Succ = 1,
    Cmd_Type_Device_Control,
    Cmd_Type_Device_Boot,
    Cmd_Type_Guard,
    Cmd_Type_Alarm,
    Cmd_Type_Alarm_Reset,
    Cmd_Type_Device_Query,
    Cmd_Type_Record,
    Cmd_Type_RecordInfo,
    Cmd_Type_Play,
    Cmd_Type_Playback_Control,

    //以下为服务器部分新加
    Cmd_Type_Device_Response,
    Cmd_Type_Notify,

    //End
    Cmd_Type_Error
};

enum{
    Cmd_Type_Device_Control_Ptz_Left = 1,
    Cmd_Type_Device_Control_Ptz_Right,
    Cmd_Type_Device_Control_Ptz_Up,
    Cmd_Type_Device_Control_Ptz_Down,
    Cmd_Type_Device_Control_Ptz_LeftUp,
    Cmd_Type_Device_Control_Ptz_LeftDown,
    Cmd_Type_Device_Control_Ptz_RightUp,
    Cmd_Type_Device_Control_Ptz_RightDown,
    Cmd_Type_Device_Control_Ptz_Stop,
    Cmd_Type_Device_Control_Ptz_SetPreset,
    Cmd_Type_Device_Control_Ptz_GotoPreset,
    Cmd_Type_Device_Control_Ptz_DelPreset,
    Cmd_Type_Device_Control_Visi_Inc,
    Cmd_Type_Device_Control_Visi_Out,
    Cmd_Type_Device_Control_Visi_Stop,
    Cmd_Type_Device_Control_All_Stop,

    Cmd_Type_Device_Control_Error
};

enum{
    Cmd_Type_Device_Query_Catalog = 1,
    Cmd_Type_Device_Query_DeviceInfo,
    Cmd_Type_Device_Query_DeviceStatus,
    Cmd_Type_Device_Query_PresetList,

    Cmd_Type_Device_Query_Error
};

enum{
    Cmd_Type_Device_Response_Catalog = 1,
    Cmd_Type_Device_Response_DeviceInfo,
    Cmd_Type_Device_Response_DeviceStatus,
    Cmd_Type_Device_Response_PresetList,

    Cmd_Type_Device_Response_Error
};

enum{
    Cmd_Type_Record_Start = 1,
    Cmd_Type_Record_Stop,

    Cmd_Type_Record_Error
};

enum{
    Cmd_Type_Guard_Start = 1,
    Cmd_Type_Guard_Stop,

    Cmd_Type_Guard_Error
};

enum{
    Cmd_Type_AlarmMethod_All,
    Cmd_Type_AlarmMethod_Phone = 1,
    Cmd_Type_AlarmMethod_Device,
    Cmd_Type_AlarmMethod_Message,
    Cmd_Type_AlarmMethod_GPS,
    Cmd_Type_AlarmMethod_Video,
    Cmd_Type_AlarmMethod_Fault,
    Cmd_Type_AlarmMethod_Other,

    Cmd_Type_AlarmMethod_Error
};

enum {
    Cmd_Type_Play_Realtime = 1,
    Cmd_Type_Play_Realtime_Ack = 2,
    Cmd_Type_Play_Back,
    Cmd_Type_Play_Back_Ack,
    Cmd_Type_Play_Download,
    Cmd_Type_Play_Download_Ack,
    Cmd_Type_Play_Stop,

    Cmd_Type_Play_Error
};

enum {
    Cmd_Playback_Control_Play = 1,
    Cmd_Playback_Control_Pause = 2,
    Cmd_Playback_Control_Teardown,

    Cmd_Playback_Control_Error
};

struct Cmd_Header{
public:
    Cmd_Header() : mi_cmd_type( Cmd_Type_Error ){

    }

    std::string m_str_cmd_type;
    std::string m_str_seqno;
    std::string m_str_device_id;
    int mi_cmd_type;
};

struct Cmd_Register_Succ : public Cmd_Header{
public:
    Cmd_Register_Succ() : Cmd_Header(){

    }

    std::string m_str_date;
};

struct Cmd_Device_Control : public Cmd_Header {
public:
    Cmd_Device_Control() : Cmd_Header()
        , mi_ptz_cmd( Cmd_Type_Device_Control_Error )
        , mi_visi_cmd( Cmd_Type_Device_Control_Error )
        , mi_preset(0)
    {

    }

    int mi_ptz_cmd;
    int mi_visi_cmd;
    int mi_preset;
};

struct Cmd_Device_Boot : public Cmd_Header {

};

struct Cmd_Device_Query : public Cmd_Header {
public:
    Cmd_Device_Query() : Cmd_Header()
      , mi_query_type( Cmd_Type_Device_Query_Error ){

    }

    int mi_query_type;
};

struct Cmd_Guard : public Cmd_Header {
public:
    Cmd_Guard() : Cmd_Header()
      , mi_guard_flag(Cmd_Type_Guard_Error){

    }

    std::string m_str_request_from_url;
    int mi_guard_flag;
};

struct Cmd_Alarm : public Cmd_Header {
public:
    std::string m_str_alarm_priority;
    std::string m_str_alarm_time;
    std::string m_str_alarm_method;
};

struct Cmd_Alarm_Reset : public Cmd_Header{
public:
    Cmd_Alarm_Reset() : Cmd_Header()
      , mi_alarm_method( Cmd_Type_AlarmMethod_Error ){

    }

    std::string m_str_request_from_url;
    int mi_alarm_method;
};

struct Cmd_Record : public Cmd_Header{
public:
    Cmd_Record() : Cmd_Header()
      , mi_record_flag( Cmd_Type_Record_Error ){

    }

    int mi_record_flag;
};

struct Cmd_Record_Info : public Cmd_Header{
public:
    std::string m_str_starttime;
    std::string m_str_endtime;
    std::string m_str_filepath;
    std::string m_str_address;
    std::string m_str_secrecy;
    std::string m_str_type;
    std::string m_str_recordId;
};

struct Cmd_Play : public Cmd_Header{
public:
    Cmd_Play() : Cmd_Header()
      , mi_play_flag( Cmd_Type_Play_Error )
      , mi_call_id( 0 )
      , mi_play_did( 0 )
      , mi_tid( 0 ){
        m_str_starttime = "0";
        m_str_endtime = "0";
        m_str_port = "6000";
        m_str_protocoltype = "RTP/AVP";

        m_str_tcp_setup.clear();
        m_str_tcp_connection.clear();
        m_str_callid_value.clear();
        m_str_callid_host.clear();
        m_str_downloadspeed = "1";
    }

    int mi_play_flag;
    std::string m_str_ip;
    std::string m_str_port;
    std::string m_str_starttime;
    std::string m_str_endtime;
    std::string m_str_ssrc;
    std::string m_str_protocoltype;
    std::string m_str_tcp_setup;//passive or active
    std::string m_str_tcp_connection;//new ?
    std::string m_str_downloadspeed;
    int mi_call_id;
    int mi_play_did;
    int mi_tid;
    std::string m_str_callid_value;
    std::string m_str_callid_host;
};

struct Cmd_PlaybackControl : public Cmd_Header{
public:
    Cmd_PlaybackControl() : Cmd_Header()
      , mi_playback_control_type(Cmd_Playback_Control_Error)
      , mi_call_id( 0 )
      , mi_play_did( 0 )
      , mi_tid( 0 ){
        m_str_callid_value.clear();
        m_str_callid_host.clear();
        m_str_scale.clear();
        m_str_pausetime.clear();
        m_str_range_begin.clear();
        m_str_range_end.clear();
    }

    int mi_playback_control_type;
    int mi_call_id;
    int mi_play_did;
    int mi_tid;
    std::string m_str_callid_value;
    std::string m_str_callid_host;

    std::string m_str_scale;
    std::string m_str_pausetime;
    std::string m_str_range_begin;
    std::string m_str_range_end;
};

// 通道信息结构体
struct Device_Channel {
public:
    Device_Channel(){
        str_device_channel_id.clear();
        str_name.clear();
        str_manufacturer.clear();
        str_model.clear();
        str_status.clear();
        str_address.clear();
        str_parent_id.clear();
    }
    std::string str_device_channel_id;    // 通道ID
    std::string str_name;        // 通道名称
    std::string str_manufacturer;// 厂商
    std::string str_model;       // 型号
    std::string str_status;      // 状态(ON/OFF)
    std::string str_address;     // 地址
    std::string str_parent_id;    // 父设备ID
};
// Catalog响应结构体
struct Catalog_Response : public Cmd_Header {
public:
    Catalog_Response() : Cmd_Header(){
        i_sunnum = 0;
        st_channel_vec.clear();
    }
    int i_sunnum;              // 通道总数
    std::vector<Device_Channel> st_channel_vec; // 通道列表
};

//DeviceInfo响应结构体
struct DeviceInfo_Response : public Cmd_Header {
public:
    DeviceInfo_Response() : Cmd_Header(){
        str_result.clear();
        str_device_name.clear();
        str_manufacturer.clear();
        str_model.clear();
        str_fireware.clear();
        i_channel_num = 0;
    }

    std::string str_result;
    std::string str_device_name;
    std::string str_manufacturer;
    std::string str_model;
    std::string str_fireware;
    int i_channel_num;
};

//DeviceStatus响应结构体
struct DeviceStatus_Response : public Cmd_Header {
public:
    DeviceStatus_Response() : Cmd_Header(){

    }

    std::string str_result;
    std::string str_online;
    std::string str_status;
    std::string str_device_time;

    std::string str_encode;
    std::string str_record;
};

struct Preset_Item {
public:
    Preset_Item(){
        i_id = 0;
        str_preset_name.clear();
    }

    int i_id;
    std::string str_preset_name;
};
struct PresetList_Response : public Cmd_Header {
public:
    PresetList_Response() : Cmd_Header(){
        i_num = 0;
        st_preset_vec.clear();
    }

    int i_num;              // 总数
    std::vector<Preset_Item> st_preset_vec; // 列表
};

struct Record_Info_Item {
public:
    Record_Info_Item(){
        str_device_id.clear();
        str_name.clear();
        str_file_path.clear();
        str_address.clear();
        str_start_time.clear();
        str_end_time.clear();
        i_secrecy = 0;
        str_type.clear();
        ui_file_size = 0;
    }

    std::string str_device_id;
    std::string str_name;
    std::string str_file_path;
    std::string str_address;
    std::string str_start_time;
    std::string str_end_time;
    int i_secrecy;
    std::string str_type;
    unsigned int ui_file_size;
};

struct RecordInfo_Response : public Cmd_Header {
public:
    RecordInfo_Response() : Cmd_Header(){
        str_name.clear();
        i_sum_num = 0;
        st_record_info_vec.clear();
    }

    std::string str_name;
    int i_sum_num;              // 总数
    std::vector<Record_Info_Item> st_record_info_vec; // 列表
};

struct MediaStatus_Notify : public Cmd_Header {
public:
    MediaStatus_Notify() : Cmd_Header(){
        str_notify_type.clear();
    }

    std::string str_notify_type;
};


//设备注册与注销回调
typedef void (*on_device_register_cb)(const char *pc_dev_id, unsigned int ui_register_expires, void *p_user);

//DeviceInfo
typedef void (*on_device_info_cb)(const char *pc_dev_id, DeviceInfo_Response st_device_info, void *p_user);

//DeviceStatus
typedef void (*on_device_status_cb)(const char *pc_dev_id, DeviceStatus_Response st_device_status, void *p_user);

//CataLog数据回调
typedef void (*on_device_catalog_cb)(const char *pc_dev_id, Catalog_Response st_catalog, void *p_user);

//INVITE媒体播放回调
typedef void (*on_device_channel_invite_cb)(const char *pc_dev_id, const char *pc_channel_id, Cmd_Play st_play, void *p_user);

//RecordInfo
typedef void (*on_device_recordinfo_cb)(const char *pc_dev_id, RecordInfo_Response st_record, void *p_user);

//PresetList
typedef void (*on_device_presetlist_cb)(const char *pc_dev_id, PresetList_Response st_ptzs, void *p_user);


#endif
